#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	int A[9]={1,2,3,4,5,6,7,8,9};
	int n;
	scanf("%d",&n);
	sort(A,A+n);
	do
	{
		for(int i=0;i<n;i++)
		{
			printf("%d",A[i]);
		}
		printf("\n");
	}
	while(next_permutation(A,A+n));
	return 0;
}
